<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>滴滴法律</title>
	<link rel="stylesheet" type="text/css" href="css/normalize.css">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<!--[if lt IE 9]> 
		<script> src="js/html5shiv.min.js"></script> 
	<![endif]-->
</head>
<body>
	<div class="well well-sm">律师管理 / 审核律师信息</div>
	<form class="form-horizontal" method="post" action="" id="agree-form" style="margin-top:10px;">
	  <div class="form-group">
	    <label class="col-sm-2 control-label">照片</label>
	    <div class="col-sm-4">
	      <img src="http://localhost:8080/${lawyers.idcardimg}" alt="头像" width="120" height="150">
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="user-input" class="col-sm-2 control-label">姓名</label>
	    <div class="col-sm-4">
	      <input type="hidden" name="lawyerid" value="${lawyers.lawyerid}">
	      <input type="text" class="form-control" id="name" value="${lawyers.name}" name="name" >
	    </div>
	  </div>
	  <div class="form-group">
	    <label class="col-sm-2 control-label">性别</label>
	    <div class="col-sm-4">
		    <label class="radio-inline">
				  <input type="radio" name="sex" id="inlineRadio1" value="1" <c:if test="${lawyers.sex == '1'}">checked</c:if>> 男
				</label>
				<label class="radio-inline">
				  <input type="radio" name="sex" id="inlineRadio2" value="2" <c:if test="${lawyers.sex == '2'}">checked</c:if>> 女
				</label>
			</div>
	  </div>
	  <div class="form-group">
	    <label for="user-input" class="col-sm-2 control-label">邮箱</label>
	    <div class="col-sm-4">
	      <input type="text" class="form-control" id="mail" value="${lawyers.mail}" name="mail">
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="user-input" class="col-sm-2 control-label">律师号</label>
	    <div class="col-sm-4">
	      <input type="text" class="form-control" id="operationnum" value="${lawyers.operationnum}" name="operationnum">
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="tel-input" class="col-sm-2 control-label">年限</label>
	    <div class="col-sm-4">
	      <c:if test="${lawyers.membership == 1}"><input type="text" class="form-control" id="membership" value="5年以下" name="membership"></c:if>
	      <c:if test="${lawyers.membership == 2}"><input type="text" class="form-control" id="membership" value="5~10年" name="membership"></c:if>
	      <c:if test="${lawyers.membership == 3}"><input type="text" class="form-control" id="membership" value="10年以上" name="membership"></c:if>
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="user-input" class="col-sm-2 control-label">城市</label>
	    <div class="col-sm-2">
	      <select class="form-control" name="province">
	      	<option value="${lawyers.province}">${lawyers.provinceName}</option>
	      </select>
	    </div>
	    <div class="col-sm-2">
	      <select class="form-control" name="city">
	      	<option value="${lawyers.city}">${lawyers.cityName}</option>
	      </select>
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="user-input" class="col-sm-2 control-label">擅长</label>
	    <div class="col-sm-2">
	      <select class="form-control" name="speciala">
	      	<option value="${lawyers.speciala}">${lawyers.specialNameA}</option>
	      </select>
	    </div>
	    <div class="col-sm-2">
	      <select class="form-control" name="specialb">
	      	<option value="${lawyers.specialb}">${lawyers.specialNameB}</option>
	      </select>
	    </div>
	    <div class="col-sm-2">
	      <select class="form-control" name="specialc">
	      	<option value="${lawyers.specialc}">${lawyers.specialNameC}</option>
	      </select>
	    </div>
	  </div>
	  <div class="form-group">
	  	<div class="col-sm-offset-2 col-sm-4">
	  		<input type="text" class="form-control" id="lawoffice" value="${lawyers.lawoffice}" name="lawoffice">
	  	</div>
	  </div>
	  <div class="form-group">
	  	<div class="col-sm-offset-2 col-sm-4">
	  		<input type="text" class="form-control" value="${lawyers.officeaddress}" id="officeaddress" name="officeaddress">
	  	</div>
	  </div>
	  <div class="form-group">
	  	<div class="col-sm-offset-2 col-sm-4">
	  		<textarea class="form-control" id="intro" placeholder="请填写律师介绍" rows="3" name="intro">填认真填写律师简介</textarea>
	  	</div>
	  </div>
	  <div class="form-group">
	    <div class="col-sm-offset-2 col-sm-10">
	      <button type="button" id="update-btn" class="btn btn-success">修改</button>
	      <a href="lawyer/auditLawyer"><button type="button" id="refuse" class="btn btn-danger">返回</button></a>
	    </div>
	  </div>
	</form>
</body>
<script type="text/javascript">
	$("#update-btn").on('click',function(){
		var flag = true;
		var name = $('#name').val();
		var mail = $('#mail').val();
		var operationnum = $('#operationnum').val();
		var membership = $('#membership').val();
		var lawoffice = $('#lawoffice').val();
		var officeaddress = $('#officeaddress').val();
		var intro = $('#intro').val();
		if (name == "") {
		 	alert("请填写正确的姓名！");
		 	flag = false;
		 }else if (mail == "") {
		 	alert("请填写正确的邮箱！");
		 	flag = false;
		 }else if (operationnum == "") {
		 	alert("请填写正确的律师证件号！");
		 	flag = false;
		 }else if (membership == "") {
		 	alert("请填写正确的年限！");
		 	flag = false;
		 }else if (lawoffice == "") {
		 	alert("请填写正确的律所名字！");
		 	flag = false;
		 }else if (officeaddress == "") {
		 	alert("请填写正确的律所地址！");
		 	flag = false;
		 }else if (intro == "") {
		 	alert("请填写正确的简介！");
		 	flag = false;
		 }
		 if (flag) {
		 	$.ajax({
        	type:"post",
        	url:"lawyer/update",
        	data:$('#agree-form').serialize(),
        	success:function(data){
        		alert(data.msg);
        		if (data.code == 200) {
        			location.href = "lawyer/auditLawyer";
        		}else{
        			alert("修改失败！请重试！");
        		}
        	  }
			});
		  }
		});
		
		$("#refuse").on('click',function(){
		 	var applyId = $("input[name='applyId']").val();
		 	$.ajax({
        	type:"get",
        	url:"lawyer/refuse/" + applyId,
        	success:function(data){
        		alert(data.msg);
        		if (data.code == 200) {
        			location.href = "lawyer/auditWaitLawyer";
        		}else{
        			alert("操作失败！请重试！");
        		}
        	  }
			});
		});
</script>
</html>